#ifndef __QUEUE_H__
#define __QUEUE_H__

#include <types.h>

typedef struct queue queue_t;

struct queue {
    queue_t *next;
    queue_t *prev;
};

#define queue_init(head)	((head)->next = (head)->prev = (head))
#define queue_empty(head)	((head)->next == (head))
#define queue_next(q)		((q)->next)
#define queue_prev(q)		((q)->prev)
#define queue_first(head)	((head)->next)
#define queue_last(head)	((head)->prev)
#define queue_end(head,q)	((q) == (head))

/* Get the struct for this entry */
#define queue_entry(q, type, member) \
    ((type *)((char *)(q) - (unsigned long)(&((type *)0)->member)))

void enqueue(queue_t *head, queue_t *item);
queue_t *dequeue(queue_t *head);
void queue_insert(queue_t *prev, queue_t *item);
void queue_remove(queue_t *item);

#endif	/* _QUEUE_H_ */

